#include "RBMNeuron.h"

#include "../Utils/RandomUtil.h"

CRBMNeuron::CRBMNeuron(int inDimension) :
	m_W(1, inDimension),
	m_V(1, 1),
	m_B(0.0)
{
	for (int i = 0; i < inDimension; i++)
	{
		this->m_W[i][0] = RandomUtil::GenGaussianRandomNumber(0.0, 0.01);
	}
}

double CRBMNeuron::Sample(const Matrix2 & vData)
{
	Matrix2 matWT = this->m_W;
	Matrix2::Transpose(this->m_W, matWT);

	Matrix2::Multiply(matWT, vData, this->m_V);

	return 1.0 / (1.0 + ::exp(-1.0 * this->m_V[0][0]));
}

const Matrix2 & CRBMNeuron::GetWeight()
{
	return this->m_W;
}

void CRBMNeuron::SetWeight(const Matrix2 & w)
{
	this->m_W = w;
}

double CRBMNeuron::GetBias()
{
	return this->m_B;
}

void CRBMNeuron::SetBias(double b)
{
	this->m_B = b;
}